package com.core;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;

/**
 * 对象父类，实现Serializable接口 1. 重写equals和hashCode方法：根据id来判断对象的相等 子类必须有id的属性
 * 
 * @author xiawu
 */
@MappedSuperclass
@Searchable
public  class BaseBean implements Serializable {

	// 如果不加版本号的时候 关联查询 会报com.isweat.bean.xxx cannot be cast to java.io.Serializable
	private static final long serialVersionUID = 5674301313143471012L; 


	protected Integer id;// ID   
	protected Date create_date;// 创建日期
	protected Date modify_date;// 修改日期
	
	@SearchableId
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Temporal(TemporalType.TIMESTAMP)  // 默认为timestamp
	@Column(updatable=false)
	public Date getCreate_date() {
		return create_date;
	}
	public void setCreate_date(Date create_date) {
		this.create_date = create_date;
	}
	public Date getModify_date() {
		return modify_date;
	}
	public void setModify_date(Date modify_date) {
		this.modify_date = modify_date;
	}
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this,
				ToStringStyle.SHORT_PREFIX_STYLE);
	}

}
